<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #app {
        width: 500px;
        justify-content: center;
        text-align: center;
        /* border: 1px solid grey; */
      }
      * {
        margin: 0 auto;
      }
    </style>
  </head>
  <body>
    <script src="./vue.js"></script>
    <div id="app">
      <div>
        <p>欢迎光临_vue开发的收银系统_水果店</p>
        <table border="1" width="600" height="100">
          <tr>
            <td>苹果{{price}}￥/斤，折扣<8折></td>
          </tr>
          <tr>
            <td>
              请输入你要购买的斤数<input type="text" v-model.number="num" />
            </td>
          </tr>
          <tr>
            <td><button @click="buy">结账买单~</button></td>
          </tr>
          <tr>
            <td>
              结账单：总价:{{totalPrice}}元 折后价：{{totalPrice*0.8}}元
              省了：{{totalPrice-totalPrice*0.8}}元
            </td>
          </tr>
        </table>
      </div>
    </div>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          price: 10,
          num: "",
          totalPrice: 0,
        },
        methods: {
          buy() {
            this.totalPrice = this.price * this.num;
          },
        },
      });
    </script>
  </body>
</html>
